package com.penghaonan.appframework.utils

import com.google.gson.JsonElement
import com.google.gson.JsonNull
import com.google.gson.JsonObject

class GsonUtils {
}

fun JsonObject.getSafety(key: String): JsonElement? {
    if (this.has(key)) {
        try {
            val element = this.get(key)
            if (element is JsonNull) {
                return null
            }
            return element
        } catch (e: Exception) {
            Logger.e(e)
            return null
        }
    }
    return null
}